fix: skip files not having extraction functions to improve speed#32
fix: skip files not having extraction functions to improve speed#32
Conversation
c3e11ea to
582e2ec
Compare
582e2ec to
057735b
Compare
|
Code Climate has analyzed commit 057735b and detected 1 issue on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 100.0% (80% is the threshold). This pull request will bring the total coverage in the repository to 96.9% (0.0% change). View more on Code Climate. |
| private function hasFormattingFunctions(string $code, array $functions): bool | ||
| { | ||
| foreach ($functions as $function) { | ||
| if (mb_strpos($code, $function, 0, Parser::ENCODING) !== false) { |
There was a problem hiding this comment.
This will have some false positives too.... if we're looking for function foo but there is only a fooBar defined, it'd still match, right?
There was a problem hiding this comment.
Good point. There will be false positives. We're currently looking only for formatMessage, so if formatMessage appears only in a comment, this will match. That's because we haven't yet parsed the file to find out the context of the strings, so we don't know whether they're real function calls, etc.
We might be able to iterate on this to make it better at matching.
Description
Before fully parsing the code to get the parameters of the string extraction functions, we'll first check the file contents to see if any of the functions exist (using string comparison). If we don't find them in the source code, we can skip parsing the contents.
This saves on some processing time for large code bases.
Product requirements and context
How has this been tested?
PR Checklist